import React from 'react';
import { connect } from 'dva';
//引入路由需要的东西
import { Switch, Route, Redirect} from 'dva/router';
import styles from './IndexPage.less';
import { Layout } from 'antd';
import NavBar from '../components/NavBar/navBar';
import Home from './Home/home';
import Menus from './Menus/menu';
import About from './About/about';
import Manage from './Manage/manage';
import Login from './User/login';
import Register from './User/register';

//解构
const { Header, Content } = Layout;

function IndexPage(props) {
  //console.log(props);//打印props 发现有一个location中的一个属性pathname能获取当前地址栏指向的文件路径
  return (
      <Layout className={styles.layout}>
          <Header className={styles.header}>
             <NavBar {...props}></NavBar>
          </Header>
          <Content className={styles.content}>
             {/* 一级路由 */}
         <Switch>
            <Route path="/home" component={Home}></Route>
            <Route path="/menus" component={Menus}></Route>
            <Route path="/manage" component={Manage}></Route>
            <Route path="/about" component={About}></Route>
            <Route path="/login" component={Login}></Route>
            <Route path="/register" component={Register}></Route>
            {/* 以下标签是重定向 */}
            <Redirect to="/login"></Redirect>
        </Switch>
          </Content>
      </Layout>
    )

}
IndexPage.propTypes = {
};

export default connect()(IndexPage);

